plat/common: Remove duplication of plat_crash_console functions/stubs
authorJulius Werner <[email protected]>
Tue, 20 Nov 2018 21:02:27 +0000 (13:02 -0800)
committerJulius Werner <[email protected]>
Fri, 7 Dec 2018 00:09:42 +0000 (16:09 -0800)
Commit e74afb652 (Deprecate weak crash console functions) deprecated the
default inclusion of weak definitions for plat_crash_console functions
in plat/common/aarch64/platform_helpers.S. The code was later copied out
to plat/common/aarch64/crash_console_helpers.S so platforms can link it
explicitly if they want to. However, since deprecation does not mean
removal, the same code is also still duplicated in platform_helpers.S.

The duplicated code contains both empty stubs for the !MULTI_CONSOLE_API
case, and a real implementation that used to work but was broken by
commit d35cc34 (Console: Use callee-saved registers) for
MULTI_CONSOLE_API. It's not great to have both of these duplicated in
two files, so this patch splits them up: in platform_helpers.S we'll
only keep the empty stubs (guarded by !ERROR_DEPRECATED), which should
not regress functionality since the MULTI_CONSOLE_API implementation was
already broken anyway. In crash_console_helpers.S, we'll only keep the
MULTI_CONSOLE_API version, which is enough both as an implementation in
itself and as a sample for how to reimplement these functions in a
platform-specific file.

Change-Id: I83d95a90ab6aac597dc2ea2f2797ac2c8ed075d4
Signed-off-by: Julius Werner <[email protected]>
plat/common/aarch64/crash_console_helpers.S
plat/common/aarch64/platform_helpers.S

index 5af8db252775c5aafe23a88bf2a643bf88135e2c..55e7abbfcab8cce8f44259484214d68490c5e73a 100644 (file)
@@ -16,7 +16,9 @@
        .globl  plat_crash_console_putc
        .globl  plat_crash_console_flush
 
-#if MULTI_CONSOLE_API
+#if !MULTI_CONSOLE_API
+#error "This crash console implementation only works with the MULTI_CONSOLE_API!"
+#endif
 
        /* -----------------------------------------------------
         * int plat_crash_console_init(void)
@@ -68,25 +70,3 @@ endfunc plat_crash_console_putc
 func plat_crash_console_flush
        b       console_flush
 endfunc plat_crash_console_flush
-
-#else  /* MULTI_CONSOLE_API */
-
-       /* -----------------------------------------------------
-        * In the old API these are all no-op stubs that need to
-        * be overridden by the platform to be useful.
-        * -----------------------------------------------------
-        */
-func plat_crash_console_init
-       mov     x0, #0
-       ret
-endfunc plat_crash_console_init
-
-func plat_crash_console_putc
-       ret
-endfunc plat_crash_console_putc
-
-func plat_crash_console_flush
-       ret
-endfunc plat_crash_console_flush
-
-#endif
index d3ffcaf1923d0e1ef8151aa71a7b0083b8c42994..89523194d226b2f646a38a3a312fa723080cc88d 100644 (file)
@@ -40,65 +40,6 @@ func plat_report_exception
 endfunc plat_report_exception
 
 #if !ERROR_DEPRECATED
-#if MULTI_CONSOLE_API
-       /* -----------------------------------------------------
-        * int plat_crash_console_init(void)
-        * Use normal console by default. Switch it to crash
-        * mode so serial consoles become active again.
-        * NOTE: This default implementation will only work for
-        * crashes that occur after a normal console (marked
-        * valid for the crash state) has been registered with
-        * the console framework. To debug crashes that occur
-        * earlier, the platform has to override these functions
-        * with an implementation that initializes a console
-        * driver with hardcoded parameters. See
-        * docs/porting-guide.rst for more information.
-        * -----------------------------------------------------
-        */
-func plat_crash_console_init
-#if defined(IMAGE_BL1)
-       /*
-        * BL1 code can possibly crash so early that the data segment is not yet
-        * accessible. Don't risk undefined behavior by trying to run the normal
-        * console framework. Platforms that want to debug BL1 will need to
-        * override this with custom functions that can run from registers only.
-        */
-       mov     x0, #0
-       ret
-#else  /* IMAGE_BL1 */
-       mov     x3, x30
-       mov     x0, #CONSOLE_FLAG_CRASH
-       bl      console_switch_state
-       mov     x0, #1
-       ret     x3
-#endif
-endfunc plat_crash_console_init
-
-       /* -----------------------------------------------------
-        * void plat_crash_console_putc(int character)
-        * Output through the normal console by default.
-        * -----------------------------------------------------
-        */
-func plat_crash_console_putc
-       b       console_putc
-endfunc plat_crash_console_putc
-
-       /* -----------------------------------------------------
-        * void plat_crash_console_flush(void)
-        * Flush normal console by default.
-        * -----------------------------------------------------
-        */
-func plat_crash_console_flush
-       b       console_flush
-endfunc plat_crash_console_flush
-
-#else  /* MULTI_CONSOLE_API */
-
-       /* -----------------------------------------------------
-        * In the old API these are all no-op stubs that need to
-        * be overridden by the platform to be useful.
-        * -----------------------------------------------------
-        */
 func plat_crash_console_init
        mov     x0, #0
        ret
@@ -111,7 +52,6 @@ endfunc plat_crash_console_putc
 func plat_crash_console_flush
        ret
 endfunc plat_crash_console_flush
-#endif
 #endif /* ERROR_DEPRECATED */
 
        /* -----------------------------------------------------